package com.bay1ts.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.YamlProcessor.ResolutionMethod;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import com.bay1ts.service.AdminService;

@Controller
@RequestMapping("/admin")
public class AdminController {
	@Autowired
	private AdminService adminService;
	@RequestMapping
	public String showadminpage(){
		return "admin";
	}
	@RequestMapping("api")
	@ResponseBody
	public String api(){
		System.out.println("admincontroller api");
		return "aaapi";
	}
	@RequestMapping("deleteuser")
	public String showDeleteUserpage(){
		
		return "deleteuser";
	}
	@RequestMapping(value="deleteuser",method=RequestMethod.POST)
	public String deleteUser(@RequestParam("username") String username,Model model){
		model.addAttribute("username", username);
		adminService.deleteUser(username);
		return "deleteUserSuccess";
	}
}
